<?php
    #-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	Kumomado::load('Route.KumomadoAbstractRoute');
	/**
	 * @package libraries/route/
	 * @author Tsai, Min Che
	 * @version 1.0
	 */
	class KumomadoRoute extends KumomadoAbstractRoute {
		protected $route_mode;
		protected $route_class;
		public function __construct() {
			if (!defined('ROUTE_MODE')) {
				throw new KumomadoRouteException('Not defined ROUTE_MODE');
			}
			$route_mode = ucfirst(strtolower(ROUTE_MODE));
			$route_class = 'Kumomado'.$route_mode.'Route';
			if ($route_class != __CLASS__) {
				$this->route_mode = $route_mode;
				$this->route_class = $route_class;
			}
		}
		public function request() {
			//default for web
		}
		public function execute() {
			Kumomado::load('Route.'.$this->route_class);
			$route = new $this->route_class;
			if (is_subclass_of($route, 'KumomadoAbstractRoute')) {
				$route->execute();
			} else {
				throw new KumomadoRouteException('Router class must be rewrite execute method.');
			}
		}
	}
?>